package com.example.routeplansystem.controller;


import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.example.routeplansystem.anotation.UserPermissionConf;
import com.example.routeplansystem.constant.ResponseStatus;
import com.example.routeplansystem.entity.dto.ResponseEntity;
import com.example.routeplansystem.service.DistanceService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;


@RequestMapping("distance")
@RestController
@Api(tags = "距离模块")
@Validated
@UserPermissionConf
public class DistanceController {

    @Autowired
    private DistanceService distanceService;

    //计算两点距离：
    @GetMapping("generateDistance")
    @ApiOperation("得到该问题下所有点两两之间的距离")
    @ApiImplicitParam(name = "questionId", paramType = "query", value = "问题Id", required = true)
    public ResponseEntity generateDistance(@NotNull(message = "问题Id不能为空") @RequestParam("questionId") int questionId) {
        distanceService.generateDistanceFromNode(questionId);
        return new ResponseEntity<>(ResponseStatus.FAILURE_RESPONSE, "自动登录失败！！！", null);
    }

    @GetMapping("stopGenerateDistance")
    @ApiOperation("停止准备距离数据")
    @ApiImplicitParam(name = "questionId", paramType = "query", value = "问题Id", required = true)
    public ResponseEntity stopGenerateDsitance(@NotNull(message = "问题Id不能为空") Integer questionId) {
        distanceService.stopCalculateDistance(questionId);
        return new ResponseEntity<>(ResponseStatus.FAILURE_RESPONSE, "自动登录失败！！！", null);
    }
}
